package com.ocelot.san.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import com.ocelot.san.dto.Lawyer;
import com.ocelot.san.repository.LawyerRepository;

@Service
public class LawyerService {
	
	@Resource
	private LawyerRepository lawyerRepository;
	
	public void save(Lawyer lawyer) {
		lawyerRepository.save(lawyer);
	}
	
	public Lawyer findById(Long id) {
		return lawyerRepository.findOne(id);
	}

	public void delete(Long id) {
		lawyerRepository.delete(id);
	}

	
	public List<Lawyer> fetchAll() {
		return lawyerRepository.findAll(new Sort(Sort.Direction.ASC, "name"));
	}

}
